package com.anzia.study_12.utils;

import ohos.distributedschedule.interwork.DeviceInfo;
import ohos.distributedschedule.interwork.DeviceManager;

import java.util.ArrayList;
import java.util.List;

public class DeviceUtils {
	public static String getDeviceId() {
		List<DeviceInfo> deviceList = DeviceManager.getDeviceList(DeviceInfo.FLAG_GET_ONLINE_DEVICE);
		if (deviceList.isEmpty())
			return null;
		int size = deviceList.size();
		ArrayList<String> deviceIds = new ArrayList<>(size);
		ArrayList<String> deviceNames = new ArrayList<>(size);
		deviceList.forEach(device -> {
			deviceIds.add(device.getDeviceId());
			deviceNames.add(device.getDeviceName());
		});
		String deviceIdStr = deviceIds.get(0);

		return deviceIdStr;
	}
}
